package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author ChaunceyZhang
 * @date 2022-10-17 16:12
 * @blog1 https://zephyr-cyber.github.io/
 * @blog2 https://www.yuque.com/gougougou-xwscx
 */

@Component
@Aspect
public class MyAdvice {
//    @Pointcut("execution(void com.itheima.dao.BookDao.update())")
    @Pointcut("execution(* com.itheima.*.*.u*(..))")
//    @Pointcut("execution(void com.itheima.dao.BookDao.update())")
//    @Pointcut("execution(void com.itheima.dao.BookDao.update())")
    //私有方法
    //private void pt() {}

    public void pt2(){}
    //@Before("pt2()")
//    @Around("pt2()")
//    public void aroundSelect(ProceedingJoinPoint pjo) throws Throwable {
//        Signature signature = pjo.getSignature();
//        Class signatureDeclaringType = signature.getDeclaringType();
//        String declaringTypeName = signature.getDeclaringTypeName();
//        String signatureName = signature.getName();
//
//        System.out.println("around before advice");
//        Object ret = pjo.proceed();
//        System.out.println("around after advice");
//    }

    @Before("pt2()")
    public void method() {
        System.out.println("book dao update ~~~~~");
        System.out.println(System.currentTimeMillis());
    }
}
